package com.dci.service.impl.node;

import com.dci.context.Config;
import com.dci.dao.pms.node.NodeManageMapper;
import com.dci.model.node.NodeManage;
import com.dci.result.ResultInfo;
import com.dci.result.ResultUtil;
import com.dci.service.node.NodeManageService;
import com.dci.util.UUIDBuild;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * All rights Reserved, Designed By 姑苏区政府大数据中心
 *
 * @version V1.0
 * @Title: null.java
 * @Package com.dci.service.impl.node
 * @Description: 节点管理实现类
 * @author: 张星亮
 * @date: 2019/2/25
 * @Copyright: 2019 姑苏区政府大数据中心. All rights reserved.
 * 注意：本内容仅限于姑苏区政府大数据中心内部传阅，禁止外泄以及用于其他的商业目
 */
@Service
public class NodeManageServiceImpl implements NodeManageService {

    @Resource
    private NodeManageMapper nodeManageMapper;

    @Override
    public List<NodeManage> selectNode() {
        return nodeManageMapper.selectNode();
    }

    @Override
    public ResultInfo insertNode(String node) {
        NodeManage nodeManage = NodeManage.builder().id(UUIDBuild.getUUID()).node(node).build();
        int a = nodeManageMapper.deleteNode();
        int i = nodeManageMapper.insertNode(nodeManage);
        if (i > 0) {
            return ResultUtil.createSuccess(Config.MESSAGE, 906, null);
        }
        return ResultUtil.createSuccess(Config.MESSAGE, 911, null);
    }
}
